function getTitle(text){
	return "<h1 class='lineaHorizontal'><span class='square'></span><span id='resumenSearch'>" + text + " - " + getNameSearch(selectedSearch) + "</span></h1>";
}

function obtieneIndiceSelecionado(){
	if(infoSelectedSearch[1] != -1){
		var inicio = infoSelectedSearch[1].startInterval;
		var fin = infoSelectedSearch[1].endInterval;
		var dtoCount = jsonBusqueda.lstDTOCounts[0];
		var found = false;
		var i=0;
		for (;!found && i<dtoCount.lstDTOCountsInterval.length;i++) {
			var interval = dtoCount.lstDTOCountsInterval[i];
			if (interval.startInterval == inicio && interval.endInterval == fin){
				found = true;
			}
		}
		
		return found?i:-1;
	}else {
		return -1;
	}
}

function getCategories() {
	var busqueda = jsonBusqueda.lstDTOCounts[getBusqueda(infoSelectedSearch[0])];
	var result = new Array();
	for(var i = 0; i < busqueda.src.length; i++){
		result[i] = busqueda.src[i][0];
	}	
	
	return result;
}


function setCategories(chart,excluidos){
	var searchs = jsonBusqueda.lstDTOCounts;
	var categories = new Array();   
	var j = 0;
	for(var i = 0; i< searchs.length; i ++){
		if(excluidos[i] == 1){
			categories[j] = '<span id="labelSearch'+searchs[i].idSearch+'" onclick="actualizaDivComo('+searchs[i].idSearch+')">'+searchs[i].name+'</span>';
			j++;
		}			
	}
	chart.xAxis[0].setCategories(categories);	
}


function incluyeSeries(chart,excluidos){
	var indexSelected = obtieneIndiceSelecionado();
	var searchs = jsonBusqueda.lstDTOCounts; 
	var z = 0;
	for (var i = 0; i < searchs.length; i++) {
		if(excluidos[i] != 1){
			var dtoSearch = searchs[i];
			var datos = [];
			for (var j = 0; j < dtoSearch.src.length; j++) {						
					var value=dtoSearch.lstDTOCountsInterval[indexSelected].lstDTOCountsIntervalMedia[j].totalCount/150;
					datos.push({
						x : z,
						y : j,
						marker:{
							radius:value,
							}
					});									
			}
			chart.addSeries({
				showInLegend: false,
				name : dtoSearch.name,
				id : dtoSearch.idSearch,
				data : datos,
				yAxis : 0,
				marker:{
					symbol:'circle',
		            lineWidth:1,			            
		            states:{
		                hover:{
		                    enabled:false
		                }
		            }
				}
			});
			z++;	
		}		
	}
}




(function($,sr){

	  // debouncing function from John Hann
	  // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
	  var debounce = function (func, threshold, execAsap) {
	      var timeout;

	      return function debounced () {
	          var obj = this, args = arguments;
	          function delayed () {
	              if (!execAsap)
	                  func.apply(obj, args);
	              timeout = null; 
	          };

	          if (timeout)
	              clearTimeout(timeout);
	          else if (execAsap)
	              func.apply(obj, args);

	          timeout = setTimeout(delayed, threshold || 100); 
	      };
	  }
	    // smartresize 
	    jQuery.fn[sr] = function(fn){  return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); };

	})(jQuery,'smartresize');
